#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
const int N = 1e5 + 10;

int d[N], v[N], a[N], p[N];
//int nums;
int sum[N];

void solve()
{
	int n, m, L, V;
	cin >> n >> m >> L >> V;
	for (int i = 1; i <= n; i ++ )
		cin >> d[i] >> v[i] >> a[i];
	for (int i = 1; i <= m; i ++ )
		cin >> p[i];
	int res = 0;
	for (int i = 1; i <= n; i ++ )
	{
		if (d[i] > p[m]) continue;
		int vn = (v[i] * v[i]) + 2 * a[i] * (p[m] - d[i]);
		if (sqrt(vn) > V) res ++ ;
	}
	if (res == 0) cout << res << ' ' << m << endl;
	else cout << res << ' ' << m - 1 << endl;
}

int main()
{
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	ios::sync_with_stdio(false);
	int T;
	cin >> T;
	while (T -- )
	{
		memset(d, 0, sizeof d);
		memset(v, 0, sizeof v);
		memset(p, 0, sizeof p);
		memset(a, 0, sizeof a);
		solve();
	}
	
	
	
	return 0;
}
